# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit python multilib eutils

MY_PN=${PN/moiosms/MoioSMS}
MY_PV=${PV/_beta/b}

python_version
MY_D="/usr/$(get_libdir)/python${PYVER}/site-packages/moiosms"

DESCRIPTION="SMS sender for several sites (Vodafone, Rossoalice, Tim, Tin, Smshosting, Callwave, Enel)"
HOMEPAGE="http://www.moioli.net/Progetti___1/MoioSMS___Messaggi_GRATIS_da_Internet____22.html"
SRC_URI="http://www.moioli.net/files/${MY_PN}${MY_PV}-src.zip"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="ocr"

RDEPEND="virtual/python
	>dev-python/pycurl-7.15.0
	>=dev-python/wxpython-2.6
	ocr? (	>=app-text/ocrad-0.13
		>=app-text/gocr-0.39
		media-gfx/graphicsmagick )"
DEPEND="${RDEPEND}
	app-arch/unzip"


S="${WORKDIR}/${MY_PN}-${MY_PV}"

src_unpack() {
	unpack ${A}
	cd ${S}

	epatch "${FILESDIR}/graphicsmagick.patch"
	
	# Some cleanup
	find ${S} -name "*~" -exec rm {} \;
	edos2unix *.txt
}

src_install() {
	insinto "${MY_D}"
	exeinto "${MY_D}"
	doins -r moio/
	doexe sms.py
        dosym "${MY_D}"/sms.py /usr/bin/moiosms
	dodoc LEGGIMI-Linux.txt RINGRAZIAMENTI.txt

	insinto /usr/share/pixmaps/
	doins moiosms-128.xpm
        make_desktop_entry /usr/bin/moiosms MoioSMS moiosms-128.xpm "Utility;TelephonyTools"
}

pkg_postinst() {
	python_mod_optimize ${ROOT}/${MY_D}

	if ! use ocr ; then
            ewarn "Without the OCR support 'moiosms' cannot be used from"
            ewarn "the command line for the websites that use captcha"
	fi
}

pkg_postrm() {
	python_mod_cleanup
}

